﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zor_Modes;
using Zor_IDAL;
using Zor_Tools;

namespace Zor_DAL
{
    public class CommunityPreview_DAL<T> where T : class
    {

        /// <summary>
        /// 获取楼宇下拉列表
        /// </summary>
        /// <returns></returns>
        public static List<T> GetListAddress()
        {
            var dt = RequestSession.GetSessionUser().DT_Id;
            var sql = "select [Dt_Name] from [dbo].[Sys_Department] where Dt_Id in (select Dt_ParentId  from dbo.Sys_Department where Dt_Id = " + dt + ") ";
            List<T> listBuilding = DapperQuery<T>.DoQueryList(sql, null);
            return listBuilding;
        }
        /// <summary>
        /// 获取楼宇下拉列表
        /// </summary>
        /// <returns></returns>
        public static List<T> GetListSq()
        {
            var dt = RequestSession.GetSessionUser().DT_Id;
            var sql = "select [Dt_Name] from [dbo].[Sys_Department]  where Dt_Id = " + dt + " ";
            List<T> listBuilding = DapperQuery<T>.DoQueryList(sql, null);
            return listBuilding;
        }

        /// <summary>
        /// 获取GIS年度税收地图数据
        /// </summary>
        /// <returns></returns>
        public static List<T> GetSQ()
        {
            var dt = RequestSession.GetSessionUser().DT_Id;
            var sql = "select * from [dbo].[V_CommunityPreview]  where Dt_Id = " + dt + " ";
            return DapperQuery<T>.DoQueryList(sql, null);
        }

        /// <summary>
        ///获取登录的社区经纬度 
        /// </summary>
        /// <returns></returns>
        public static List<T> GetCommunityLonAndLat()
        {
            int Dtid = RequestSession.GetSessionUser().DT_Id; //获取登录的用户ID
            //string sql = "select Dt_Id,Dt_Name,Dt_BD_Longitude,Dt_BD_Latitude from [dbo].[Sys_Department] where Dt_Id = " + Dtid + "";
            string sql = "select (select Dt_Name from [Sys_Department] where Dt_Id =sd.Dt_ParentId )as SOName,sd.Dt_ParentId,sd.Dt_Id,sd.Dt_Name,sd.Dt_BD_Longitude,sd.Dt_BD_Latitude from [dbo].[Sys_Department] as sd  where sd.Dt_Id= " + Dtid + "";
            return DapperQuery<T>.DoQueryList(sql, null);
        }
    }
}
